<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    console.dir(Array);
    console.dir(String);
    console.dir(Date);


    // 自定义拓展方法 (给数组拓展的  所有的数组都可以使用)
    Array.prototype.mySlice = function (startIndex = 0, endIndex = this.length) {
        // 如果是负值  length + (-1)
        // startIndex = startIndex < 0 ? this.length + startIndex : startIndex;
        // endIndex = endIndex < 0 ? this.length + endIndex : endIndex;

        // // 超出最大值  => 等于最大值
        // endIndex = endIndex >= this.length ? this.length : endIndex;

        // this  -> 调用此方法的实例化对象   !!!!!!!!!!!!!!  arr.mySlice => arr    brr.mySlice => brr  
        var list = [];
        for (var i = startIndex; i < endIndex; i++) {
            var item = this[i]; // arr[i]
            list.push(item);
        }
        return list;
    }

    var arr = new Array(1, 2, 3, 4, 5, 6);
    // console.log(arr);
    var brr = arr.mySlice(2, 5);  //  this ->  arr
    // var brr = arr.__proto__.mySlice(2, 5);  // this -> arr.__proto__ => Array.prototype (错误)
    console.log(brr);



</script>

</html>